home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 41
/
Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso
/
-seriously_amiga-
/
misc
/
nilnull
/
null
/
misc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-04-19
|
2KB
|
104 lines
/*
** $VER: misc.c 1.0 (4.4.99)
**
** misc DOS packet routines
**
** modified 1999 by Andreas R. Kleinert
** Original Copyright below.
*/
/*
* misc.c - support routines - Phillip Lindsay (C) Commodore 1986
* You may freely distribute this source and use it for Amiga Development -
* as long as the Copyright notice is left intact.
*
* 30-SEP-86
*
*/
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/libraries.h>
#include <exec/devices.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <dos/filehandler.h>
#include <devices/console.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc.h"
/* returnpkt() - packet support routine
* here is the guy who sends the packet back to the sender...
*
* (I modeled this just like the BCPL routine [so its a little redundant] )
*/
void __saveds returnpktplain(struct DosPacket *packet, struct Process *myproc)
{
returnpkt(packet, myproc, packet->dp_Res1, packet->dp_Res2);
}
void __saveds returnpkt(struct DosPacket *packet, struct Process *myproc, ULONG res1, ULONG res2)
{
struct Message *mess;
struct MsgPort *replyport;
if(!packet) return;
if(!myproc) return;
packet->dp_Res1 = res1;
packet->dp_Res2 = res2;
replyport = packet->dp_Port;
mess = packet->dp_Link;
if(!replyport) return;
if(!mess) return;
packet->dp_Port = &myproc->pr_MsgPort;
mess->mn_Node.ln_Name = (char *) packet;
PutMsg(replyport, mess);
}
/*
* taskwait() ... Waits for a message to arrive at your port and
* extracts the packet address which is returned to you.
*/
struct DosPacket * __saveds taskwait(struct Process *myproc)
{
struct MsgPort *myport;
myport = &myproc->pr_MsgPort;
if(myport)
{
struct Message *mymess;
WaitPort(myport);
mymess = GetMsg(myport);
if(mymess) return((struct DosPacket *)mymess->mn_Node.ln_Name);
}
return(NULL);
}